<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/fns.tld" prefix="fns" %>
<!DOCTYPE HTML>
<html lang="zh-cn">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <jsp:include page="/resources/inc/pageHead.jsp" />
    <link href="${basePath}/resources/zheng-admin/plugins/zTree_v3/css/demo.css" rel="stylesheet"/>
    <link href="${basePath}/resources/zheng-admin/plugins/zTree_v3/css/metroStyle/metroStyle.css" rel="stylesheet"/>
</head>
<body>
<form class="layui-form layui-form-pane" id="_form">
    <%--基本信息--%>
    <fieldset class="layui-elem-field">
        <legend>基本信息</legend>
        <div class="layui-field-box">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">姓名</label>
                    <div class="layui-input-inline">
                        <input type="text" name="realname" lay-verify="required" autocomplete="off" placeholder="请输入姓名"
                               class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">手机号码</label>
                    <div class="layui-input-inline">
                        <input type="text" name="phone" autocomplete="off" placeholder="请输入手机号码(登录账号)"
                               class="layui-input" lay-verify="phone">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">工号</label>
                    <div class="layui-input-inline">
                        <input type="text" name="jobNumber" lay-verify="required" autocomplete="off" placeholder="请输入工号"
                               class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">身份证号</label>
                    <div class="layui-input-inline">
                        <input type="text" name="idcard" autocomplete="off" placeholder="请输入身份证号"
                               class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">性别</label>
                    <div class="layui-input-inline">
                        <select name="gender">
                            <c:forEach items="${fns:getDictList('gender')}" var="gender">
                                <option value="${gender.value}">${gender.name}</option>
                            </c:forEach>
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">出生日期</label>
                    <div class="layui-input-inline">
                        <input type="text" name="birthday" autocomplete="off"
                               placeholder="请选择出生日期"
                               class="layui-input date-select" readonly="readonly">
                    </div>
                </div>

                <div class="layui-inline">
                    <label class="layui-form-label">政治面貌</label>
                    <div class="layui-input-inline">
                        <select name="political">
                            <c:forEach items="${fns:getDictList('political')}" var="political">
                                <option value="${political.value}">${political.name}</option>
                            </c:forEach>
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">档案编号</label>
                    <div class="layui-input-inline">
                        <input type="text" name="archiveNo" autocomplete="off"
                               placeholder="请输入档案编号"
                               class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">入职时间</label>
                    <div class="layui-input-inline">
                        <input type="text" name="joinedTime" autocomplete="off" placeholder="请选择入职时间"
                               class="layui-input date-select" readonly="readonly">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">转正日期</label>
                    <div class="layui-input-inline">
                        <input type="text" name="positiveTime" autocomplete="off" placeholder="请选择转正日期"
                               class="layui-input date-select" readonly="readonly">
                    </div>
                </div>
            </div>
        </div>
    </fieldset>
    <%--工作信息--%>
    <fieldset class="layui-elem-field">
        <legend>工作信息</legend>
        <div class="layui-field-box">
            <div class="layui-form-item">
                <div class="layui-block">
                    <label class="layui-form-label">工作部门</label>
                    <div class="layui-input-inline ztreeDiv">
                        <input type="text" readonly="readonly"
                               placeholder="请选择工作部门" class="layui-input" onclick="ZtreeCommon.showMenu(this,true,20)"
                               ztreeId="organizationIdZtree">
                        <input type="hidden" name="organizationId" id="pid_value" ztreeId="organizationIdZtree">
                    </div>
                    <div class="menuContent" style="display:none; position: absolute;z-index: 10000">
                        <ul id="organizationIdZtree" class="ztree" style="margin-top:0; width:220px;"></ul>
                    </div>
                </div>
                <div class="layui-block">
                    <label class="layui-form-label">工作岗位</label>
                    <div class="layui-input-inline ztreeDiv">
                        <input type="text" readonly="readonly"
                               placeholder="请选择工作岗位" class="layui-input" onclick="ZtreeCommon.showMenu(this,true,20)"
                               ztreeId="positionIdZtree">
                        <input type="hidden" name="positionId" ztreeId="positionIdZtree">
                    </div>
                    <div class="menuContent" style="display:none; position: absolute;z-index: 10000">
                        <ul id="positionIdZtree" class="ztree" style="margin-top:0; width:220px;"></ul>
                    </div>
                </div>
            </div>

        </div>
    </fieldset>
    <%--合同信息--%>
    <fieldset class="layui-elem-field">
        <legend>合同信息</legend>
        <div class="layui-field-box">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">是否见习</label>
                    <div class="layui-input-inline">
                        <input type="radio" name="probation" value="true" title="是" checked>
                        <input type="radio" name="probation" value="false" title="否">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">见习开始时间</label>
                    <div class="layui-input-inline">
                        <input type="text" name="startProbationTime" autocomplete="off"
                               placeholder="请输入见习开始时间" class="layui-input date-select" readonly="readonly">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">见习结束时间</label>
                    <div class="layui-input-inline">
                        <input type="text" name="endProbationTime" autocomplete="off"
                               placeholder="请输入见习结束时间"
                               class="layui-input date-select" readonly="readonly">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">是否签订合同</label>
                    <div class="layui-input-inline">
                        <input type="radio" name="signed" value="true" title="是" checked>
                        <input type="radio" name="signed" value="false" title="否">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">签订合同日期</label>
                    <div class="layui-input-inline">
                        <input type="text" name="signedTime" autocomplete="off" placeholder="请选择签订合同日期"
                               class="layui-input date-select" readonly="readonly">
                    </div>
                </div>

                <div class="layui-block">
                    <label class="layui-form-label">是否兼职</label>
                    <div class="layui-input-inline">
                        <input type="radio" name="parttime" value="false" title="否" checked>
                        <input type="radio" name="parttime" value="true" title="是">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">兼职类型</label>
                    <div class="layui-input-inline">
                        <select name="parttimeType">
                            <c:forEach items="${fns:getDictList('parttime_type')}" var="type">
                                <option value="${type.value}">${type.name}</option>
                            </c:forEach>
                        </select>
                    </div>
                </div>
            </div>
        </div>
    </fieldset>
    <%--学历信息--%>
    <fieldset class="layui-elem-field">
        <legend>学历信息</legend>
        <div class="layui-field-box">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">最高学历</label>
                    <div class="layui-input-inline">
                        <select name="education">
                            <c:forEach items="${fns:getDictList('education')}" var="education">
                                <option value="${education.value}">${education.name}</option>
                            </c:forEach>
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">学历类型</label>
                    <div class="layui-input-inline">
                        <select name="educationType">
                            <c:forEach items="${fns:getDictList('education_type')}" var="type">
                                <option value="${type.value}">${type.name}</option>
                            </c:forEach>
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">毕业院校</label>
                    <div class="layui-input-inline">
                        <input type="text" name="university" autocomplete="off"
                               placeholder="请输入毕业院校"
                               class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">毕业时间</label>
                    <div class="layui-input-inline">
                        <input type="text" name="graduationTime" autocomplete="off" placeholder="请选择毕业时间"
                               class="layui-input date-select" readonly="readonly">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">所学专业</label>
                    <div class="layui-input-inline">
                        <input type="text" name="professional" autocomplete="off"
                               placeholder="请输入所学专业"
                               class="layui-input">
                    </div>
                </div>
            </div>
        </div>
    </fieldset>
    <%--其他信息--%>
    <fieldset class="layui-elem-field">
        <legend>其他信息</legend>
        <div class="layui-field-box">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">工龄</label>
                    <div class="layui-input-inline">
                        <input type="text" name="workage" autocomplete="off" placeholder="请输入工龄"
                               class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">招聘渠道</label>
                    <div class="layui-input-inline">
                        <input type="text" name="channel" autocomplete="off" placeholder="请输入招聘渠道"
                               class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">备注</label>
                    <div class="layui-input-block">
                        <textarea name="remarks" placeholder="请输入备注" class="layui-textarea"></textarea>
                    </div>
                </div>
            </div>

        </div>
    </fieldset>
    <%--工作经历--%>
    <fieldset class="layui-elem-field">
        <legend>工作经历</legend>
        <div class="layui-field-box" id="experience">
            <div class="layui-form-item" experienceDiv="true">
                <div class="layui-inline">
                    <label class="layui-form-label">公司名</label>
                    <div class="layui-input-inline">
                        <input type="text" autocomplete="off" placeholder="请输入公司名" class="layui-input"
                               experienceName="company">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">岗位</label>
                    <div class="layui-input-inline">
                        <input type="text" autocomplete="off" placeholder="请输入岗位" class="layui-input"
                               experienceName="position">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">公司地点</label>
                    <div class="layui-input-inline">
                        <input type="text" autocomplete="off" placeholder="请输入公司地点" class="layui-input"
                               experienceName="location">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">工作年限</label>
                    <div class="layui-input-inline">
                        <input type="text" autocomplete="off" placeholder="请输入工作年限" class="layui-input"
                               experienceName="year">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">入职日期</label>
                    <div class="layui-input-inline">
                        <input type="text" autocomplete="off" placeholder="请输入入职日期"
                               class="layui-input date-select" readonly="readonly" experienceName="startTime">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">离职日期</label>
                    <div class="layui-input-inline">
                        <input type="text" autocomplete="off" placeholder="请输入离职日期"
                               class="layui-input date-select" readonly="readonly" experienceName="endTime">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">备注</label>
                    <div class="layui-input-inline">
                        <input experienceName="remarks" type="text" placeholder="请输入备注" class="layui-input">
                    </div>
                </div>
                <a href="javascript:void(0)" onclick="deleteDiv(this)">删除经历</a>
            </div>
            <div>
                <a onclick="addExperience(this)" href="javascript:void(0)">添加工作经历</a>
            </div>
        </div>
    </fieldset>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="" lay-filter="sub">立即提交</button>
        </div>
    </div>
</form>
<jsp:include page="/resources/inc/pageFooter.jsp" />
<script src="${basePath}/resources/zheng-admin/js/my-ztree-common.js"></script>
<script>
    var laydate;
    var experience = $("div[experienceDiv='true']");
    var organizationZNodes = getOrganizationTree(true, false);
    var positionZNodes = getPositionTree(true, false);
    function addExperience(button) {
        var expDiv = $(experience.clone(true)[0]);
        expDiv.find("input").val("");
        $(button).parent().before(expDiv);
        $(expDiv).find(".date-select").each(function (index, input) {
            laydate.render({
                elem: this //指定元素
                , theme: '#393D49'
            });
        });

    }
    function deleteDiv(a) {
        $(a).parent().remove();
    }
    FormCommon.initForm({
        url: '${basePath}/oa/hr/personalRecords/create',
        subContentType: "json",
        subId: "sub",
        editData: function (data) {
            data.joinedTime = new Date(data.joinedTime).getTime();
            data.birthday = new Date(data.birthday).getTime();
            data.graduationTime = new Date(data.graduationTime).getTime();
            data.positiveTime = new Date(data.positiveTime).getTime();
            data.signedTime = new Date(data.signedTime).getTime();
            data.desertTime = new Date(data.desertTime).getTime();
            data.startProbationTime = new Date(data.startProbationTime).getTime();
            data.endProbationTime = new Date(data.endProbationTime).getTime();
            var experiences = [];
            var experienceDivs = $("#experience").find(".layui-form-item");
            experienceDivs.each(function (index, experienceDiv) {
                var experience = {};
                experience.company = $(experienceDiv).find("input[experienceName='company']").val();
                experience.position = $(experienceDiv).find("input[experienceName='position']").val();
                experience.location = $(experienceDiv).find("input[experienceName='location']").val();
                experience.year = $(experienceDiv).find("input[experienceName='year']").val();
                experience.startTime = $(experienceDiv).find("input[experienceName='startTime']").val();
                experience.endTime = $(experienceDiv).find("input[experienceName='endTime']").val();
                experience.remarks = $(experienceDiv).find("input[experienceName='remarks']").val();
                experiences.push(experience);
            });
            data.experiences = experiences;
            return data;
        }
    });
    $(function () {
        $.fn.zTree.init($("#organizationIdZtree"), ZtreeCommon.radioAllSetting, organizationZNodes);
        $.fn.zTree.init($("#positionIdZtree"), ZtreeCommon.radioAllSetting, positionZNodes);
        layui.use('laydate', function () {
            laydate = layui.laydate;
            $(".date-select").each(function (index, input) {
                laydate.render({
                    elem: this //指定元素
                    , theme: '#393D49'
                });
            });
        });
    });
</script>
</body>
</html>
